﻿using System.Web.Mvc;
using DevFramework.Core.Infrastructure;

namespace DevFramework.MvcUI.Filters
{
    public class NoAuthority : ActionFilterAttribute
    {
        private readonly int _actionId;

        public NoAuthority(int islemId)
        {
            _actionId = islemId;
        }

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!AuthorizeTool.Authorize(_actionId))
            {
                filterContext.Result = new ViewResult
                {
                    ViewName = "NoAuthorize",
                };

                //HttpContext.Current.Response.RedirectToRoute("Default", new { controller = "Home", action = "YetkiYok" });
            }

            base.OnActionExecuting(filterContext);
        }
    }
}